package com.ynkbny.tasks;

import com.ynkbny.aspect.TaskOperationLog;
import com.ynkbny.service.BaseJob;
import com.ynkbny.service.LaoGouApiService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class QueryProjectList implements BaseJob {

    @Resource
    private LaoGouApiService service;

    /**
     * 查询所有项目列表，维护“项目表”
     *
       0 15 10 * * ?    每天上午10:15触发
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    @TaskOperationLog(description = "查询所有项目列表，维护“项目表”")
    public void execute(JobExecutionContext jobExecutionContext) {
        log.info("自动任务：‘查询所有项目列表，维护“项目表”’ 开始");
        service.queryProjectList();
        log.info("自动任务：‘查询所有项目列表，维护“项目表”’ 结束");
    }
}
